package com.monlyu.action.statistics;

import java.util.List;
import java.util.Map;

import com.google.common.collect.Maps;
import com.monlyu.action.PageAction;
import com.monlyu.bo.StatisticsBo;
import com.monlyu.model.CountFGModel;
import com.monlyu.model.QueryModel;

/**
 * @author SongJun
 * @since 2010-3-1
 * @description
 */
public class StatisticsAction extends PageAction {
	// private Pages<Manuscript> ms;
	private StatisticsBo statisticsBo;
	private QueryModel qm;
	private String type;
	private Long msid;
	// private List<GaoJian2Reporter> gjrs;
	private List<CountFGModel> gjrs;

	public List<CountFGModel> getGjrs() {
		return gjrs;
	}

	public void setGjrs(List<CountFGModel> gjrs) {
		this.gjrs = gjrs;
	}

	public Long getMsid() {
		return msid;
	}

	public void setMsid(Long msid) {
		this.msid = msid;
	}

	public void setType(String type) {
		this.type = type;
	}

	public QueryModel getQm() {
		return qm;
	}

	public void setQm(QueryModel qm) {
		this.qm = qm;
	}

	public void setStatisticsBo(StatisticsBo statisticsBo) {
		this.statisticsBo = statisticsBo;
	}

	public String statistics() {
		String url = getOrderURL(type);
		if (qm != null) {
			gjrs = statisticsBo.countFG(qm);
		}
		return view(url);
	}

	public String getOrderURL(String type) {
		return initMapType().get(type);
	}

	private static Map<String, String> typeMap = Maps.newLinkedHashMap();

	public Map<String, String> initMapType() {
		if (typeMap.isEmpty()) {
			typeMap.put("fgtj", "fgStatistics.jsp");
			/**
			 * typeMap.put("cstj", "user.name;csStatistics.jsp".split(";"));
			 * typeMap.put("dytj", "user.name;dyStatistics.jsp".split(";"));
			 * typeMap.put("lmtj", "user.name;lmStatistics.jsp".split(";"));
			 * typeMap.put("tctj", "user.name;tcStatistics.jsp".split(";"));
			 * typeMap.put("lbtj", "user.name;lbStatistics.jsp".split(";"));
			 * typeMap.put("ddtj", "user.name;ddStatistics.jsp".split(";"));
			 * typeMap.put("dftj", "user.name;dfStatistics.jsp".split(";"));
			 */
		}
		return typeMap;
	}
	/**
	 * public String toView(){ gjrs =
	 * statisticsBo.getGJRStatistics(getDefPage(), msid); return
	 * view("gaoJian2Reporter.jsp"); }
	 */

	// 2.1 记者发稿统计 type = fgtj
	// 2.2 播出次数统计 type = cstj
	// 1.1 地域统计 type = dytj
	// 2.3 栏目统计 type = lmtj
	// 2.4 稿件题材统计 type = tctj
	// 2.5 稿件类别统计 type = lbtj
	// 2.7 稿件打等统计 type = ddtj
	// 2.8 稿件打分排行榜 type = dftj
}
